/*
 * GameListener.cpp
 *
 *  Created on: 2013-1-23
 *      Author: heqiu
 */

#include "GameListener.h"
#include "Global.h"

void GameListener::handleEvents(GuudEvent &stEvent) {
	g_GlobalData.m_GuudLock.lock();

	if (g_GlobalData.m_pGuudCanvasWelcome != NULL) {
		g_GlobalData.m_pGuudCanvasWelcome->handleEvent(stEvent);
	}
	if (g_GlobalData.m_pGuudCanvasControl != NULL) {
		g_GlobalData.m_pGuudCanvasControl->handleEvent(stEvent);
	}
	if (g_GlobalData.m_pGuudCanvasMap != NULL) {
		g_GlobalData.m_pGuudCanvasMap->handleEvent(stEvent);
	}

	if (stEvent.type == SDL_KEYDOWN) {
		if (stEvent.key.keysym.sym == SDLK_ESCAPE) {
			g_GlobalData.m_pGuudCanvasWelcome->m_bListen =
					!g_GlobalData.m_pGuudCanvasWelcome->m_bListen;
			g_GlobalData.m_pGuudCanvasWelcome->m_bShow =
					g_GlobalData.m_pGuudCanvasWelcome->m_bListen;
		}
	}
	g_GlobalData.m_GuudLock.unlock();
}

void GameListener::gameQuit() {
	pressed_button_exit(NULL,NULL);
}
